{% extends 'base.html' %}

{% load i18n %}
{% load l10n %}
{% load staticfiles %}

{% block title %}{% trans "Validations submited" %} - Wapyce{% endblock %}
{% block content %}
<div class="row">
  <div class="col-md-10 col-md-offset-1">
    <h2>{% trans "Validations submited" %}</h2>
    <div class="table-responsive">
      <table class="table table-striped table-bordered table-hover">
        <thead>
          <tr>
            <th>{% trans "UUID" %}</th>
            <th>{% trans "Site" %}</th>
            <th>{% trans "User" %}</th>
            <th>{% trans "Start date" %}</th>
            <th>{% trans "End date" %}</th>
            <th>{% trans "Validation status" %}</th>
          </tr>
        </thead>
        <tbody>
          {% for validation in object_list %}
            <tr>
              <td><a href="{% url 'detail_validation' validation.uuid %}">{{ validation.uuid }}</a></td>
              <td><a href="{{ validation.site.base_url }}" target="_blank">{{ validation.site.base_url }}</a></td>
              <td><a href="https://github.com/{{ validation.user }}" target="_blank">{{ validation.user }}</a></td>
              <td>{{ validation.start_date|localize }}</td>
              <td>{{ validation.end_date|localize }}</td>
              <td>{{ validation.get_status_display }}</td>
            </tr>
          {% endfor %}
        </tbody>
      </table>
    </div>
    {% if is_paginated %}
      <div class="pagination">
        <nav aria-label="Page navigation">
          <ul class="pagination">
            {% if page_obj.has_previous %}
              <li>
                <a href="{% url 'list_validations' %}?page={{ page_obj.previous_page_number }}" aria-label="{% trans 'Previous' %}">
                  <span aria-hidden="true">&laquo;</span>
                </a>
              </li>
            {% else %}
              <li class="disabled">
                <span><span aria-hidden="true">&laquo;</span></span>
              </li>
            {% endif %}
            {% with ''|center:page_obj.paginator.num_pages as range %}
              {% for _ in range %}
                {% if page_obj.number == forloop.counter %}
                  <li class="active"><span>{{ forloop.counter }} <span class="sr-only">({% trans "current" %})</span></span></li>
                {% else %}
                  <li><a href="{% url 'list_validations' %}?page={{ forloop.counter }}">{{ forloop.counter }}</a></li>
                {% endif %}
              {% endfor %}
            {% endwith %}
            {% if page_obj.has_next %}
              <li>
                <a href="{% url 'list_validations' %}?page={{ page_obj.next_page_number }}" aria-label="{% trans 'Next' %}">
                  <span aria-hidden="true">&raquo;</span>
                </a>
              </li>
            {% else %}
              <li class="disabled">
                <span><span aria-hidden="true">&raquo;</span></span>
              </li>
            {% endif %}
          </ul>
        </nav>
      </div>
    {% endif %}
  </div>
</div>
{% endblock %}
